package com.tencent.stat.common;

import android.content.Context;
import com.tencent.stat.NetworkManager;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.json.JSONObject;

public class a
{
  static c a;
  private static StatLogger d = StatCommonHelper.getLogger();
  private static JSONObject e = new JSONObject();
  Integer b = null;
  String c = null;

  public a(Context paramContext)
  {
    try
    {
      a(paramContext);
      this.b = StatCommonHelper.getTelephonyNetworkType(paramContext.getApplicationContext());
      this.c = NetworkManager.getInstance(paramContext).getCurNetwrokName();
      return;
    }
    catch (java.lang.Throwable paramContext)
    {
      d.e(paramContext);
    }
  }

  static c a(Context paramContext)
  {
    monitorenter;
    try
    {
      if (a == null)
        a = new c(paramContext.getApplicationContext(), null);
      paramContext = a;
      return paramContext;
    }
    finally
    {
      monitorexit;
    }
  }

  public static void a(Context paramContext, Map paramMap)
  {
    if (paramMap == null)
      return;
    paramContext = new HashMap(paramMap).entrySet().iterator();
    while (true)
    {
      if (paramContext.hasNext());
      paramMap = (Map.Entry)paramContext.next();
      e.put((String)paramMap.getKey(), paramMap.getValue());
    }
  }

  public void a(JSONObject paramJSONObject, Thread paramThread)
  {
    JSONObject localJSONObject = new JSONObject();
    try
    {
      if (a != null)
        a.a(localJSONObject, paramThread);
      Util.jsonPut(localJSONObject, "cn", this.c);
      if (this.b != null)
        localJSONObject.put("tn", this.b);
      if (paramThread == null)
      {
        paramJSONObject.put("ev", localJSONObject);
        if ((e == null) || (e.length() <= 0))
          return;
        paramJSONObject.put("eva", e);
        return;
      }
      paramJSONObject.put("errkv", localJSONObject.toString());
    }
    catch (java.lang.Throwable paramJSONObject)
    {
      d.e(paramJSONObject);
    }
  }
}